package com.example.Equipment.controller;

import com.example.Equipment.domain.Equipment;
import com.example.Equipment.service.EquipmentService;
import com.example.JavaDemo.domain.Community;
import com.example.comon.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;



    @RestController
    @CrossOrigin//支持跨域
    @RequestMapping("/magazine")
    @Api(value = "magazine",tags = "社区台账管理")
    public class EquipmentController {
        @Autowired
        private EquipmentService equipmentService;

        @GetMapping("/getEquipmentList")
        @ApiOperation("获取器材列表")
        public R<List<Equipment>> getEquipmentList(Equipment equipment){
            List<Equipment> list =  equipmentService.selectEquipment(equipment);
            return R.success(list);
        }



        @PostMapping("/addEquipment")
        @ApiOperation("增加器材")
        public R<Equipment> addEquipment(@RequestBody Equipment equipment){
            equipmentService.insertEquipment(equipment);
            return R.success(equipment);
        }

        @PostMapping("/updateEquipmentById")
        @ApiOperation("修改器材")
        public R<List<Community>> updateEquipmentById(@RequestBody Equipment equipment){
            equipmentService.updateEquipmentById(equipment);
            return R.success();
        }

        @DeleteMapping("/deleteEquipmentById")
        @ApiOperation("删除器材")
        public R<List<Community>> deleteEquipmentById(String Id){
            equipmentService.deleteEquipmentById(Id);
            return R.success();
        }

    }



